const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const powerSchema = new Schema(
  {
    deviceId: String,
    device: String,
    voltage: String,
    current: String,
    runTime: String,
    consumption: String,
    temperature: String,
    type: String
  },
  {
    toObject: {
      transform: function (doc, ret) {
        delete ret._id;
        delete ret.__v;
      },
    },
    toJSON: {
      transform: function (doc, ret) {
        delete ret._id;
        delete ret.__v;
      },
    },
  }
);

const oltSchema = new Schema({
  power: powerSchema,
  mcud: String,
  mpwd: String,
  gpfd: String,
});
const Power = mongoose.model("Power", powerSchema);

module.exports = {
  power: mongoose.model("power", powerSchema),
  olt: mongoose.model("olt", oltSchema),
  ont: mongoose.model("power", powerSchema),
  mdu: mongoose.model("power", powerSchema),
  powerSchema,
  Power,
};
